# import re
# import requests
# from requests import RequestException
# import time
# import random
# from lxml import etree
#
#
# def get_page(url):
#     try:
#         headers = {
#             'Referer': 'https://blog.csdn.net',  # 伪装成从CSDN博客搜索到的文章
#             'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36'
#             # 伪装成浏览器
#         }
#         response = requests.get(url, headers=headers)
#         if response.status_code == 200:
#             return response.text
#         return None
#     except RequestException:
#         print('请求出错')
#         return None
#
#
# def parse_page(html):
#     try:
#         # read_num = int(re.compile('<span.*?count.*?(\d+).*?</span>').search(html).group(1))
#         html = etree.HTML(html)
#         read_num = html.xpath("//div[@class='profile-intro d-flex']")
#         return read_num
#     except Exception as e:
#         print(e)
#         return None
#
#
# def main():
#     try:
#         while 1:
#             url = 'https://blog.csdn.net/swustzhaoxingda/article/details/104822305'  # 待刷浏览量博客的url
#             html = get_page(url)
#             if html:
#                 read_num = parse_page(html)
#                 if read_num:
#                     print('当前阅读量：', read_num)
#             url = 'https://blog.csdn.net/swustzhaoxingda/article/details/104822095'  # 待刷浏览量博客的url
#             html = get_page(url)
#             if html:
#                 read_num = parse_page(html)
#                 if read_num:
#                     print('当前阅读量：', read_num)
#             url = 'https://blog.csdn.net/swustzhaoxingda/article/details/104819035'  # 待刷浏览量博客的url
#             html = get_page(url)
#             if html:
#                 read_num = parse_page(html)
#                 if read_num:
#                     print('当前阅读量：', read_num)
#             url = 'https://blog.csdn.net/swustzhaoxingda/article/details/104818005'  # 待刷浏览量博客的url
#             html = get_page(url)
#             if html:
#                 read_num = parse_page(html)
#                 if read_num:
#                     print('当前阅读量：', read_num)
#             sleep_time = random.randint(60, 83)
#             print('please wait', sleep_time, 's')
#             time.sleep(sleep_time)  # 设置访问频率，过于频繁的访问会触发反爬虫
#     except Exception:
#         print('出错啦！')
#
#
# if __name__ == '__main__':
#     main()
# import xlrd
#
# file = "D:\liuliu\工作\消息类型汇总.xlsx"
#
# # def read_excel():
# #     wb = xlrd.open_workbook(filename=file)  # 打开文件
# #     print(wb.sheet_names())  # 获取所有表格名字  #[sheet1,sheet2,sheet3]
# #
# #     sheet1 = wb.sheet_by_index(0)  # 通过索引获取表格  #[sheet2]
# #     # sheet2 = wb.sheet_by_name('班级')#通过名字获取表格
# #     # print(sheet1)
# #     print(sheet1.name, sheet1.nrows, sheet1.ncols)  # 获取总的行，列数
# #     rows = sheet1.row_values(3)  # 获取行内容
# #     cols = sheet1.col_values(2)  # 获取列内容
# #     print(rows)
# #     print(cols)
# #     data = []
# #     for i in range(3, sheet1.nrows):
# #         data.append(sheet1.row_values(i)[1:])
# #         # print(i)
# #     print(data)
# # print(sheet1.cell(1,0).value)#获取表格里的内容，三种方式
# # print(sheet1.cell_value(1,0))
# # print(sheet1.row(1)[0].value)
# # cla = sheet1.row_values(0)
# # i = cla.index('姓名')
# # n = cla.index('课别')
# # d = cla.index('工号')
# # print(cla)
# # print(i,n,d)
# # print(type(i))
# # cols = sheet1.col_values(i)  # 获取列内容
# # print(cols)
# # for x in range(sheet1.nrows):
# # print(sheet1.cell(x, i).value)
# # a = (sheet1.cell(x, i).value)
# # print(sheet1.cell(x, n).value)
# # print(sheet1.cell(x, d).value)
#
#
# # read_excel()
#
# # import gevent
# # def f(n):
# #     for i in range(n):
# #         print(gevent.getcurrent(), i)  # gevent.getcurrent()表示当前对象
# #         gevent.sleep(1)
# #     # g1 = gevent.spawn(f, 5)
# #     # g2 = gevent.spawn(f, 5)
# #     # g3 = gevent.spawn(f, 5)
# #     # g1.join()# 等待g1完成
# #     # g2.join()
# #     # g3.join()
# #     # 上面的代替写法
# #     gevent.joinall([
# #         gevent.spawn(f, 5),
# #         gevent.spawn(f, 5)
# #     ])
# # f(5)
#
# # 不同数据库转移数据
# # 导入:
# from sqlalchemy import Column, String, create_engine, Integer, Text, TIMESTAMP
# from sqlalchemy.orm import sessionmaker

# from sqlalchemy.ext.declarative import declarative_base
#
# # 创建对象的基类:
# Base = declarative_base()
#
#
# # 定义User对象:
# class TInfo(Base):
#     # 表的名字:
#     __tablename__ = 't_info'
#
#     # 表的结构:
#     id = Column(Integer, primary_key=True)
#     k = Column(String)
#     v = Column(Text)
#     t = Column(TIMESTAMP)


# 初始化数据库连接:
# engine = create_engine('mysql+pymysql://root:r00t123@10.66.1.123:3306/sddci')
# # 创建DBSession类型:
# DBSession = sessionmaker(bind=engine)
# # 实例化
# session = DBSession()
#
# ret = session.query(TInfo).filter(TInfo.k.like('%20200731%')).all()
# print(type(ret), ret)


# 测试doctest
# python文档测试
# def average(values):
#     """
#     compute average value
#
#     >>> print(average([20, 30, 10]))
#     20.0
#
#     >>>
#     上面测试的语法>>> 后面需要空一格，否则测试缩进错误
#     测试完如果文档还需要写其它注释，则以>>>  结尾，否则这段注释
#     也会被当为上面测试的输出结果，这样明显不是我们希望的输出结果
#     :param values:
#     :return:
#     """
#     return sum(values) / 0
#
#
# import doctest
#
# doctest.testmod()


# import psutil
#
# # cpu个数
# print(psutil.cpu_count())  # 默认返回逻辑cpu个数
# print(psutil.cpu_count(logical=False))  # logical为false返回物理cpu个数
#
# # cpu利用率
# print(psutil.cpu_percent()) # cpu利用率
# print(psutil.cpu_percent(percpu=True,interval=2)) # percpu为True时显示所有物理核心的利用率,interval不为0时,则阻塞时显示interval执行的时间内的平均利用率
#
# # cpu时间花费(命名元祖的形式返回)
# print(psutil.cpu_times())
# print(psutil.cpu_times(percpu=True)) # percpu=True表示获取每个cpu的时间花费
#
# # cpu耗时比例
# print(psutil.cpu_times_percent())
# print(psutil.cpu_times_percent(percpu=True)) # percpu=True表示获取每个cpu的时间花费
#
# # 以命名元组的形式返回CPU的统计信息，包括上下文切换，中断，软中断和系统调用次数
# print(psutil.cpu_stats())
#
# # 返回cpu频率
# print(psutil.cpu_freq())
#
#
# # 以命名元组的形式返回内存使用情况，包括总内存，可用内存，内存利用率，buffer和cache等。单位为字节
# print(psutil.virtual_memory())
#
# # 以命名元组的形式返回swap/memory使用情况，包含swap中页的换入和换出
# print(psutil.swap_memory())


# 使用pytz处理时区问题
from datetime import datetime, timedelta


# import pytz
#
# print(pytz.all_timezones)  # 获取全部timezone
# utc = pytz.utc
# print(utc.zone)
#
# beijing = pytz.timezone('Asia/Shanghai')  # 设置时区
# print(beijing.zone)
#
# tokyo = pytz.timezone('Asia/Tokyo')
# print(tokyo.zone)

# 上海时间
# fmt = '%Y-%m-%d %H:%M:%S %Z%z'
# loc_dt = beijing.localize(datetime(2020, 11, 10, 12, 0, 0))
# print(loc_dt.strftime(fmt))
#
# # 东京时间
# jp_dt = loc_dt.astimezone(tokyo)
# print(jp_dt.strftime(fmt))
#
# # 时差
# timestamp = datetime.utcnow()
# dt_cn = beijing.localize(timestamp)
# dt_jp = tokyo.localize(timestamp)
# x = dt_cn - dt_jp
# print(int(x.total_seconds() / 3600))
#
# # pytz保存的为本地时间，US/Eastern地区的时间与utc存在差异，并不是正确的Eastern时间，可用normalize来纠正这个问题
# utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)
# eastern = pytz.timezone('US/Eastern')
# loc_dt = utc_dt.astimezone(eastern)
# before = loc_dt - timedelta(minutes=10)
# print(before.strftime(fmt))
# print(eastern.normalize(before).strftime(fmt)) # 纠正
# after = eastern.normalize(before + timedelta(minutes=20))
# print(after.strftime(fmt))

# dateutil
# from dateutil.relativedelta import relativedelta
# from dateutil.easter import easter
# from dateutil.rrule import rrule, YEARLY, FR
# from dateutil.parser import parse
#
# now = parse('2020')  # 将任意格式的时间字符串整理成时间对象，没指定年份默认为今年，没指定月份默认为本月，没指定日期默认为今天
# today = now.date()
# # rrule说明
# # freq:可以理解为单位。可以是 YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY。即年月日周时分秒
# # dtstart,until:是开始和结束时间
# # wkst:周开始时间。
# # interval:间隔。
# # count:指定生成多少个。
# # byxxx:指定匹配的周期
# d = rrule(YEARLY, dtstart=now, bymonth=8, bymonthday=13, byweekday=FR)[0]
# year, month, day = d.year, d.month, d.day
# # relativedelta：年/月/日之间的大范围加减
# # easter:计算复活节的时间
# rdelta = relativedelta(easter(year), today)
# print("今天: %s" % today)  # 2020-10-10
# print("下一个8.13为周五在的-年/月/日: %s/%s/%s" % (year, month, day))  # 2021/8/13
# print("那年复活节距离现在有多久？: %s" % rdelta)  # relativedelta(months=+5, days=+25)
# print("那年的复活节日期: %s" % (today + rdelta))  # 2021-04-04
# d = {'id': 9229, 'name': "xiix"}
# # d = {'name': "xiix", 'id': 9229}
# new_dict = {i[0]: i[1] for i in sorted(d.items(), key=lambda d: d[0])}
# print(new_dict)


# from greenlet import greenlet
# import time
# def task_1():
#     while True:
#         print("------1-----")
#         gr2.switch() # 手动切换到gr2
#         time.sleep(0.1)
# def task_2():
#     while True:
#         print("------2-----")
#         gr1.switch() # 手动切换到gr1
#         time.sleep(0.1)
# gr1 = greenlet(task_1)
# gr2 = greenlet(task_2)
# # 切换到gr1
# gr1.switch() # 最终效果为gr1和gr2交替执行

# import gevent
# def f(n):
#     for i in range(n):
#         print(gevent.getcurrent(), i)  # gevent.getcurrent()表示当前对象
#         # gevent.sleep(1) # 如果没有该句，则会按顺序执行，遇到延时，才会切换任务
#     g1 = gevent.spawn(f, 5)
#     g2 = gevent.spawn(f, 5)
#     g3 = gevent.spawn(f, 5)
#     g1.join()# 等待g1完成
#     g2.join()
#     g3.join()
#     # 上面的代替写法
#     # gevent.joinall([
#     #     gevent.spawn(f, 5),
#     #     gevent.spawn(f, 5)
#     # ])
# f(10)

# import gevent, time
# from gevent import monkey
#
# monkey.patch_all()
#
#
# def show_wait(name, t):
#     for i in range(t):
#         print(name, '等待了', i + 1, 's')
#         time.sleep(1)
#
#
# gevent.joinall([
#     gevent.spawn(show_wait, '猪猪', 5),
#     gevent.spawn(show_wait, '呆呆', 5),
#     gevent.spawn(show_wait, '汪汪', 5),
# ])
class Fibonacci(object):
    def __init__(self, all_num):
        self.all_num = all_num
        self.current_num = 0
        self.a = 0
        self.b = 1

    def __iter__(self):
        return self

    def __next__(self):
        if self.current_num < self.all_num:
            ret = self.a
            self.a, self.b = self.b, self.a + self.b
            self.current_num += 1
            return ret
        else:
            raise StopIteration


#
#
# fibo = Fibonacci(10)
# for num in fibo:
#     print(num)

import time

# print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1628265600)))
# print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1628265600)))

# print(329.79 + 1428.24 + 3 * 470.43 + 5 * 957.81 + 644.10 * 12)
import itertools

node = [1, 2, 3, 4, 5]
m = list(itertools.combinations(node, 2))
print(m)
